﻿@model DLULearningNetwork.ViewModels.BasicInfoViewModel
@if (false)
{ 
    <script type="text/javascript" src="../../Scripts/jquery-1.5.1-vsdoc.js"></script>
}
@{
    HtmlHelper.ClientValidationEnabled = true;
}
<script type="text/javascript">
    function SubmitBasicInfo() {
        $.post("/Profile/SavingBasicInfo", $("#basicInfoForm").serialize(), function (data) {
            $("#basicInfoForm").parent().html(data);
            $("button").button();
        });
        return false;
    }
</script>
@using (Html.BeginForm("SavingBasicInfo", "Profile", FormMethod.Post, new { id = "basicInfoForm", Class = "myForm" }))
{
    <div class="title">
        Cập nhật thông tin cơ bản</div>
    <div class="formRow">
        <div class="colLeft">
            Tên :</div>
        <div class="colRight">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>
    </div>  
    <div class="clear">
    </div>
    <div class="formRow">
        <div class="colLeft">
            Họ :</div>
        <div class="colRight">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>
    </div>
    <div class="clear">
    </div>
    <div class="formRow">
        <div class="colLeft">
            Ngày sinh :</div>
        <div class="colRight">
            @Html.TextBox("DateOfBirth", Model.DateOfBirth, new { id = "DateOfBirth", Class = "datetimePicker" });
            @Html.ValidationMessageFor(model => model.DateOfBirth)
            <script type="text/javascript">
                $(".datetimePicker").datepicker({
                    dateFormat: "dd/mm/yy",
                    appendText: "dd/mm/yyyy",
                    changeMonth: true,
                    changeYear:true,
                    constrainInput: true,
                    minDate: new Date(1800, 1 - 1, 1),
                    maxDate: new Date(@DateTime.Now.Year,@DateTime.Now.Month-1,@DateTime.Now.Day),
                    autoSize: true
                });
            </script>
        </div>
    </div>
    <div class="clear">
    </div>
    <div class="formRow">
        <div class="colLeft">
            Giới tính :</div>
        <div class="colRight">
            @Html.DropDownListForSex("Sex", Model.Sex)
            @Html.ValidationMessageFor(model => model.Sex)
        </div>
    </div>
    <div class="clear">
    </div>
    <div class="formRow">
        <div class="colLeft">
            Câu hỏi bí mật :</div>
        <div class="colRight">
            @Html.DropDownListFor(model => model.SecurityQuestion, new SelectList(ViewBag.LstSecurityQuestion, "SecurityQuestionID_u", "Content_s", Model.SecurityQuestion))
            @Html.ValidationMessageFor(model => model.SecurityQuestion)
        </div>
    </div>
    <div class="clear">
    </div>
    <div class="formRow">
        <div class="colLeft">
            Trả lời :</div>
        <div class="colRight">
            @Html.EditorFor(model => model.SecurityAnswer)
            @Html.ValidationMessageFor(model => model.SecurityAnswer)
        </div>
    </div>
    
    <div class="clear">
    </div>
    <div class="formRow">
        <div class="colLeft">
            <button onclick="SubmitBasicInfo();return false;">
                Cập nhật</button></div>
    </div>
    <div class="colRight">
        @if (ViewBag.Success != null)
        {
            if (ViewBag.Success == true)
            {
            <p>
                Cập nhật thành công</p> 
            }
            else
            {
            <p>
                Có lỗi khi cập nhật, xin vui lòng thử lại sau
            </p>
            }
        }
    </div>
}
